Skip to main content

Quick Start

ALPHA VERSION

This SDK is currently in alpha development and is actively being worked on. It is not production-ready and may contain bugs, breaking changes, or incomplete features. Use at your own risk and avoid deploying to mainnet without thorough testing.

Welcome to the AssemblyScript Stylus SDK - a comprehensive development toolkit for creating Arbitrum Stylus smart contracts using TypeScript syntax, transpiled to AssemblyScript and compiled to WebAssembly for near-native execution speeds.

What is AssemblyScript Stylus SDK?

The AssemblyScript Stylus SDK is a complete development framework that allows developers to write smart contracts using familiar TypeScript decorators and syntax. Stylus is Arbitrum's next-generation smart contract platform that enables developers to write contracts in languages other than Solidity, compiling them to WebAssembly for superior performance and gas efficiency.

Requirements

  • Node.js >= 18.x
  • AssemblyScript >= 0.27.x
  • cargo stylus (Rust CLI tool for Stylus validation and deployment)

Generate a new project

Create a new contract project with built-in scaffolding:

npx @wakeuplabs/as-stylus generate my-contract
cd my-contract

This creates a complete project structure with:

  • Contract template
  • Configuration files
  • Package dependencies
  • Build scripts

Your First Contract

The generator creates a simple counter contract for you:

import { Contract, External, U256, U256Factory, View } from "@wakeuplabs/as-stylus";

@Contract
export class Counter {
counter: U256;

constructor() {
this.counter = U256Factory.create();
}

@External
set(value: U256): void {
this.counter = value;
}

@External
increment(): void {
const delta: U256 = U256Factory.fromString("1");
this.counter = this.counter.addUnchecked(delta);
}

@External
decrement(): void {
const delta: U256 = U256Factory.fromString("1");
this.counter = this.counter.subUnchecked(delta);
}

@View
get(): U256 {
return this.counter;
}
}

Build and Deploy

Compile your contract to WebAssembly and validate it for Stylus:

# build artifacts, Compile to WASM and check Validate with cargo stylus
npx @wakeuplabs/as-stylus compile contract.ts --endpoint <RPC_URL>

Deploy to Arbitrum:

npm run deploy contract.ts --private-key <PRIVATE_KEY> --endpoint <RPC_URL> --constructor-args <constructor-args...>"

Clean Artifacts

npm run clean

This command will remove all the artifact folder.

Next Steps

Ready to dive deeper? Check out the Project Breakdown to understand the SDK's architecture and components, or explore our comprehensive guides: